const constants   = require('../../data/constants');
const cameraModel = require('../../model/camera');
const sipServer  = require('../../sip/server');
let Camera={

    /**
     * API接口，获取设备列表
     * TODO: 加分页和条件查询，返回加分页变量
     * @param {*} req 
     * @param {*} res 
     */
    list:function (req, res){
        cameraModel.list().then((rows)=>{
            let ret =Object.assign(constants.httpCode.OK , {data:{items:rows,total:rows.length}});
            res.send(ret);
        });
    },

    /**
     * 请求目录
     * @param {*} req 
     * @param {*} res 
     */
    catalog:function(req,res){
      console.log(req.query);
      let account = req.query.account;
      sipServer.catalog(account);
      let ret =Object.assign(constants.httpCode.OK , {data:{}});
      res.send(ret);
    },
    delcamera:function(req,res){
      cameraModel.del(req.body.account);
      let ret =Object.assign(constants.httpCode.OK , {data:{}});
      res.send(ret);
    }
};

module.exports=Camera;